package com.zt.bigdata.spark.common.message

/**
  *
  */

import com.fasterxml.jackson.databind.node.ObjectNode
import com.zt.bigdata.common.utils.JsonHelper
import org.apache.spark.internal.Logging

object NotifyMessage extends Logging {
  val Ding_Talk = "DING"
  val Email = "EMAIL"
  val SMS = "SMS"

  def buildDingTextMessage(receivers: String, msg: String, isAtAll: Boolean = false): ObjectNode = {
    val objJson = JsonHelper.createObjectNode()
    val subObjJson = JsonHelper.createObjectNode()
    val text = JsonHelper.createObjectNode()

    if (receivers != null)
      subObjJson.set("atMobiles", JsonHelper.toJson(receivers.split(",")))
    text.put("content", msg)
    subObjJson.put("isAtAll", isAtAll)
    objJson.put("msgtype", "text")
    objJson.set("text", text)
    objJson.set("at", subObjJson)
    objJson
  }
}
